package com.hex.ds.hdtp.core.inf.data.contrast.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hex.ds.hdtp.core.inf.data.contrast.mapper.IContrastTaskTemplateMapper;
import com.hex.ds.hdtp.core.inf.data.contrast.po.ContrastTaskTemplatePo;
import com.hex.ds.hdtp.core.inf.data.contrast.repository.IContrastTaskTemplateRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.data.contrast.repository.impl
 * @ClassName ContrastTaskTemplateRepository
 * @Description: 跨库比对任务和模板关系-数据接口实现类
 * @Author: wz.li
 * @Date 2023/7/25 18:53
 * @Version v2.0.2
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ContrastTaskTemplateRepository implements IContrastTaskTemplateRepository {

    private final IContrastTaskTemplateMapper contrastTaskTemplateMapper;

    /*
     * @Method: add <br>
     * @Param: [contrastTaskTemplatePo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/25 18:53 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer add(ContrastTaskTemplatePo contrastTaskTemplatePo) {
        return contrastTaskTemplateMapper.insert(contrastTaskTemplatePo);
    }

    /**
     * @Method modifyById
     * @Param
     * @param contrastTaskTemplatePo
     * @Return java.lang.Integer
     * @Description 根据ID修改
     * @Author Wang zhihao
     * @Date 2023/8/1 19:31
     * @Version V1.0
     */
    @Override
    public Integer modifyById(ContrastTaskTemplatePo contrastTaskTemplatePo) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("task_pk_id", contrastTaskTemplatePo.getTaskPkId());
        return contrastTaskTemplateMapper.update(contrastTaskTemplatePo, queryWrapper);
    }

    /*
     * @Method: removeByTaskPkId <br>
     * @Param: [taskPkId] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据对比任务删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/7/25 18:53 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer removeByTaskPkId(String taskPkId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("task_pk_id", taskPkId);
        return contrastTaskTemplateMapper.delete(queryWrapper);
    }

    /**
     * @Method queryTemplatePkIdByTaskPkId
     * @Param 
     * @param taskPkId 
     * @Return java.util.List<java.lang.String>
     * @Description 根据任务主键查询模板主键
     * @Author Wang zhihao
     * @Date 2023/7/31 13:49
     * @Version V1.0
     */
    @Override
    public List<String> queryTemplatePkIdByTaskPkId(String taskPkId) {
        return contrastTaskTemplateMapper.queryTemplatePkIdByTaskPkId(taskPkId);
    }
}
